
<!--_meta 作为公共模版分离出去-->
{include file="public/_meta"}

<div class="page-container">
	<form action="" method="get" class="form form-horizontal" id="form-cate-add">
		<div class="row cl">
			<label class="form-label col-xs-4 col-sm-2">
				<span class="c-red">*</span>
				分类名称：</label>
			<div class="formControls col-xs-6 col-sm-6">
				<input type="text" class="input-text" value="" placeholder="" id="name" name="name">
			</div>
		</div>
		<div class="row cl">
			<label class="form-label col-xs-4 col-sm-2">所属分类：</label>
			<div class="formControls col-xs-6 col-sm-6">
				<span class="select-box">
					<select id="cate_id" name="id" class="select">
						<option value="0">顶级分类</option>
						{volist name="product_category" id="vo"}
							<option value="{$vo.id}">{$vo.level}级分类{$vo.name}</option>
						{/volist}
					</select>
				</span>
			</div>
		</div>
		<div class="row cl">
			<div class="col-9 col-offset-2">
				<input id="add_product_category" class="btn btn-primary radius" type="submit" value="&nbsp;&nbsp;提交&nbsp;&nbsp;">
			</div>
		</div>
	</form>
</div>

<!--_footer 作为公共模版分离出去-->
{include file="public/_footer"}


<script type="text/javascript">
	$("#form-cate-add").validate({
		rules:{
			name:{
				required:true,
			},
		},
		onkeyup:false,
		focusCleanup:true,
		success:"valid",
		submitHandler:function(form){
			var name = document.getElementById('name').value;
			//var cate_id = document.getElementById('cate_id');
			var id = $('#cate_id').find("option:selected").val();
			$(form).ajaxSubmit({
				url : "{:url('product/add_product_category_ajax')}",
				type : 'get',
				dataType : 'json',
				data : {id:id,name:name},
				async : false,
				success : function(data){
					if(data == true){
						layer.msg('添加产品分类成功!',{icon: 6,time:1000});
						setTimeout(jump,1000);
						function jump(){
							parent.location.reload();
						}
					}else if(data == false){
						layer.msg('添加产品分类失败!',{icon: 5,time:1000});
					}
				}
			});
		}
	});
</script>
